<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
	<form action="${pageContext.request.contextPath}/selectBanJiCourse?method=add" method="post">
		<select id="banji" name="banjiId">
			<option>--请选择--</option>
		</select>
		<select id="course" name="courseId">
			<option>--请选择--</option>
		</select><br/>
		<input type="submit" value="注册"/>
	</form>
	<script src="${pageContext.request.contextPath}/lib/jquery/jquery-1.11.1.js" type="text/javascript" charset="utf-8"></script>
	<script type="text/javascript">
		$(function(){
			$.ajax({
				url : "${pageContext.request.contextPath}/selectBanJiCourse?method=selectBanJi",
				dataType : "json",
				type : "POST",
				success : function(jsonObj){
					console.log(jsonObj);
					var html = "<option>--请选择--</option>";
					for(var i=0;i<jsonObj.length;i++){
						html += "<option value='"+jsonObj[i].id+"'>"+jsonObj[i].name+"</option>";
					}
					$("#banji").html(html);
				}
			})
			
			$.ajax({
				url : "${pageContext.request.contextPath}/selectBanJiCourse?method=selectCourse",
				dataType : "json",
				type : "POST",
				success : function(jsonObj){
					console.log(jsonObj);
					var html = "<option>--请选择--</option>";
					for(var i=0;i<jsonObj.length;i++){
						html += "<option value='"+jsonObj[i].id+"'>"+jsonObj[i].name+"</option>";
					}
					$("#course").html(html);
				}
			})
			
		});
		
	</script>

</body>
</html>